/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import domain.Map;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JPanel;

/**
 *
 * @author Teddy
 */
public class MapPanel extends JPanel implements MouseMotionListener,MouseListener {

    private Map _map;
    private MainFrame _frame;

    public MapPanel(Map map,MainFrame frame) {
        super();
        _map = map;
        _frame = frame;
        this.addMouseMotionListener(this);
    }

    @Override
    public void paint(Graphics g) {
        int width = this.getWidth()/Map.MAP_WIDTH;
        int height = this.getHeight()/Map.MAP_HEIGHT;
        int x = 0;
        int y = 0;
        g.setColor(Color.BLACK);
        for(int i=0;i<Map.MAP_HEIGHT;i++){
            x = 0;
            for(int j=0;j<Map.MAP_WIDTH;j++){
                g.drawRect(x, y, width, height);
                x = x + width;
            }
            y = y + height;
        }
     //   super.paint(g);
    }

    public void mouseDragged(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseMoved(MouseEvent e) {
        int width = this.getWidth()/Map.MAP_WIDTH;
        int height = this.getHeight()/Map.MAP_HEIGHT;
        int x = e.getX()/width;
        int y = e.getY()/height;
        _frame.showText(_map.getNode(x, y).toString());
    }

    public void mouseClicked(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mousePressed(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseReleased(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseEntered(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseExited(MouseEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }


}
